﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Lookup - 选择负责人</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />

    
    <script src="../../scripts/boot.js" type="text/javascript"></script>
    
    <style type="text/css">
        .New_Button, .Edit_Button, .Delete_Button, .Update_Button, .Cancel_Button
        {
            font-size:11px;color:#1B3F91;font-family:Verdana;  
            margin-right:5px;
        }
    </style>        
</head>
<body>
    <h1>Lookup - 选择负责人</h1>      
    <input type="button" value="save" onclick="saveData()"/>

    <div id="dept_grid" class="mini-datagrid" style="width:600px;height:280px;" allowResize="true"
        url="../data/AjaxService.jsp?method=GetDepartments"  idField="id"        
        allowCellSelect="true" allowCellEdit="true"
    >
        <div property="columns">     
            <div type="indexcolumn"></div>
            <div field="id" width="60" headerAlign="center" align="center">ID</div>                                        
            <div field="name" width="120" headerAlign="left" >部门名称</div>          
            <div field="manager" displayField="manager_name" name="manager" width="120" headerAlign="left" >负责人               
                <input property="editor" id="lookup2" class="mini-lookup" style="width:100%;" textField="name" valueField="id" popupWidth="auto" 
                    popup="#gridPanel" grid="#datagrid1" multiSelect="true" onshowpopup="onShowPopup" />
            </div>
        </div>
    </div>     
    
    <!--选择面板-->
    <div id="gridPanel" class="mini-panel" title="header" iconCls="icon-add" style="width:450px;height:250px;" visible="false"
        showToolbar="true" showCloseButton="true" showHeader="true" bodyStyle="padding:0" borderStyle="border:0" 
    >
        <div property="toolbar" style="padding:5px;padding-left:8px;text-align:center;">   
            <span>姓名：</span>    
            <input id="keyText" class="mini-textbox" style="width:160px;" onenter="onSearchClick"/>
            <a class="mini-button" onclick="onSearchClick">Search</a>       
            <a class="mini-button" onclick="onClearClick">Clear</a>      
        </div>
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
            borderStyle="border:0" showPageSize="false" showPageIndex="false"
            url="../data/AjaxService.jsp?method=SearchEmployees"
        >
            <div property="columns">
                <div type="checkcolumn" >#</div>
                <div field="loginname" width="120" headerAlign="center" allowSort="true">员工帐号</div>    
                <div field="name" width="120" headerAlign="center" allowSort="true">姓名</div>
                <div field="createtime" width="100" headerAlign="center" dateFormat="yyyy-MM-dd" allowSort="true">创建日期</div>                
            </div>
        </div>  
    </div>

    <script type="text/javascript">
        mini.parse();

        var dept_grid = mini.get("dept_grid");
        var grid = mini.get("datagrid1");
        var win = mini.get("selectWindow");
        var keyText = mini.get("keyText");

        dept_grid.load();

        //-----------------------------------------

        function saveData() {            
            var data = dept_grid.getChanges();
            
            dept_grid.loading("保存中，请稍后......");
            var json = mini.encode(data);
            $.ajax({
                url: "../data/AjaxService.jsp?method=SaveDepartment",
                data: { departments: json },
                success: function (text) {
                    dept_grid.reload();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });

        }
        /////////////////////////////////////////////
        function onShowPopup(e) {
            grid.load();
        }
        function onSearchClick(e) {
            grid.load({
                key: keyText.value
            });
        }
        function onClearClick(e) {
            var lookup = mini.get('lookup2');
            lookup.deselectAll();            
        }
        
    </script>

    <div class="description">
        <h3>Description</h3>
        
    </div>
</body>
</html>